<?php

declare (strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;
use Hyperf\ModelCache\Cacheable;
use Hyperf\ModelCache\CacheableInterface;

/**
 * @property int $id
 * @property string $avatar
 * @property string $nickname
 * @property string $username
 * @property string $password
 * @property string $sign
 * @property string $status
 */
class User extends Model implements CacheableInterface
{
    use Cacheable;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int'];

    public function friendInfo()
    {
        return $this->hasMany(Friend::class, 'user_id', 'id');
    }


    public function friendOtherInfo()
    {
        return $this->hasMany(Friend::class, 'friend_id', 'id');
    }

    public function groupMemberInfo()
    {
        return $this->hasMany(GroupMember::class, 'user_id', 'id');
    }


}
